﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ClientLib.MonitorState2;


namespace WpfDataBingding
{
    /// <summary>
    /// DynamicMonitor.xaml 的交互逻辑
    /// </summary>
    public partial class DynamicMonitor : UserControl
    {
        public DynamicMonitor()
        {
            InitializeComponent();
        }

        public DynamicMonitor(DeviceDynamic device)
        {
          
            InitializeComponent();
            this.Monitor_lay.DataContext = device;
            this.Monitor_lay.Uid = device.Device_ID + ":" + device.Monitor_ID;
        }

        private void buttonSet_Click(object sender, RoutedEventArgs e)
        {
            Button source = e.Source as Button;

            DockPanel panel = source.Parent as DockPanel;
          
            Collection devcollection = (Collection)Application.Current.Properties["MonitorCollection"];
           string[] parstr = panel.Uid.Split(':');
            DeviceDynamic device = devcollection.GetDevice(parstr[0],parstr[1]);
            WpfDataBingding.PageCollection.MonitorPage.DeviceStateChange newpage = new WpfDataBingding.PageCollection.MonitorPage.DeviceStateChange(device);

            NavigationService.GetNavigationService(this).Navigate(newpage);
         
           
            
        }    
    }
}
